package com.css.fxfzxczh.modules.samplingPointDataCensus.emergencystatistics.controller;

import com.css.fxfzxczh.base.response.RestResponse;
import com.css.fxfzxczh.modules.disasterSituationDataManage.emergencyReport.entity.EmergencyReport;
import com.css.fxfzxczh.modules.samplingPointDataCensus.emergencystatistics.entity.EmergencyPoint;
import com.css.fxfzxczh.modules.samplingPointDataCensus.emergencystatistics.entity.EmergencyProportion;
import com.css.fxfzxczh.modules.samplingPointDataCensus.emergencystatistics.service.EmergencyReportStatisticsService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * @Author: zhangSongRui
 * @CreateTime: 2023/02/21
 * @Description: 灾情急报统计
 */
@RestController
@RequestMapping("/emergencyReport")
@Slf4j
@Api(tags = "灾情急报统计")
public class EmergencyReportStatisticsController {
    @Resource
    private EmergencyReportStatisticsService emergencyReportStatisticsService;

    /**
     * 灾情类型分布
     * @param type
     * @return
     */
    @GetMapping("/queryAll")
    public RestResponse queryAll(String type,String xsemId){
        try{
            List<EmergencyReport> data = emergencyReportStatisticsService.queryAll(type,xsemId);
            return RestResponse.succeed(data);
        }catch (Exception e){
            String errormessage="查询失败";
            log.error(errormessage,e);
            return RestResponse.fail(errormessage);
        }
    }

    /**
     * 灾情类型占比
     * @param
     * @return
     */
    @GetMapping("/getProportion")
    public RestResponse getProportion(String xsemId){
        try{
            EmergencyProportion data = emergencyReportStatisticsService.getProportion(xsemId);
            return RestResponse.succeed(data);
        }catch (Exception e){
            String errormessage="查询失败";
            log.error(errormessage,e);
            return RestResponse.fail(errormessage);
        }
    }
}
